package hutool;

import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Author: DRevelation
 * @Date: 2021/4/27 14:51
 */
public class FileDemo {
    public static void main(String[] args) throws IOException {
        OutputFormat format = OutputFormat.createPrettyPrint();
        // 设置编码格式
        format.setEncoding("UTF-8");
        String xmlName = "D:\\abc.xml";
        //单纯的new File不会产生文件，write后才会生成
        File file = new File(xmlName);
        XMLWriter writer = new XMLWriter(new FileOutputStream(file), format);
        // 设置是否转义，默认使用转义字符
        writer.setEscapeText(false);
        writer.write("eeee");
        writer.close();
    }
}
